package com.h3c.ptability.controller;

import com.eos.common.util.Result;
import com.h3c.ptability.service.IBdPublicCalendarService;
import com.h3c.ptability.utils.AppBusinessException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公共日历表(BdPublicCalendar)表控制层
 *
 * @author makejava
 * @since 2022-07-06 13:53:57
 */
@CrossOrigin
@RestController
@RequestMapping("bdPublicCalendar")
public class BdPublicCalendarController {
    /**
     * 服务对象
     */
    @Resource
    private IBdPublicCalendarService iBdPublicCalendarService;

    @RequestMapping(value = "/queryFestivalByDate", method = RequestMethod.GET)
    public Result<List<String>> queryFestivalByDate(@RequestParam(value = "solarDateStart", defaultValue = "") String solarDateStart,
                                                    @RequestParam(value = "solarDateEnd", defaultValue = "") String solarDateEnd) {
        if (StringUtils.isBlank(solarDateEnd) || StringUtils.isBlank(solarDateStart)) {
            throw new AppBusinessException("请输入开始时间和结束时间");
        }
        List<String> list = iBdPublicCalendarService.queryFestivalByDate(solarDateStart, solarDateEnd);
        return new Result<>(true, 20000, "查询节假日成功", list);
    }

    @RequestMapping(value = "/syncBdPublicCalendar", method = RequestMethod.GET)
    public Result<List<String>> syncBdPublicCalendar() {
        iBdPublicCalendarService.syncBdPublicCalendar();
        return new Result<>(true, 20000, "查询节假日成功");
    }
}

